<?php
namespace app\index\model;
use think\Db;
use think\Model;
/*
黑名单
 */
class Blacklist extends Model
{
	//判断查询Ta有没有已经加入黑名单啦
    public static function sel($uid,$nearby_id){
    	 $rs=Db::name('user_blacklist')
                 ->where(['uid'=>$uid,'blacklist_id'=>$nearby_id])
                 ->find();
         return $rs;
    }

    public static function BlacklistAdd($data){
         $rd=Db::name('user_blacklist')
                 ->insert($data);
         return $rd;
    }
    //查询黑名单用户
    public static function BlacklistSel($uid){
         $blacklist=Db::name('user_blacklist')
                ->where(['uid'=>$uid])  
                ->field('blacklist_id')
                 ->select();
          $blacklist=array_column($blacklist,'blacklist_id'); 
          $blacklist_id=implode(',',$blacklist);
          $userList=Db::name('user_info')
                ->where('uid','in',$blacklist_id)
                ->field('uid as blacklist_id,userPhoto,nickname')  
                 ->select(); 
         return $userList;
    }
    //移除黑名单
    public static function blacklistDel($uid,$blacklist_id){
       $rs=Db::name('user_blacklist')
                ->where(['uid'=>$uid,'blacklist_id'=>$blacklist_id])  
                 ->delete();
       return $rs;     
    }
 }   